import random
def continue_game(coin):
    print("你的起始金币有：", coin, "个")
    print("错误一次损失500金币")
    a = int(input("请输入第一个数字："))
    b = int(input("请输入第二个数字："))
    while a >= b:
        b = int(input("第二个数字不能小于或等于第一个数字，请重新输入："))
    print("数字区间为（", a, "-", b, "）")
    c = random.randint(a, b)
    print("猜测开始！！！")
    d = int(input("请输入所想数字："))
    sum = 0
    playing = True
    while playing:
        if d > c:
            sum += 1
            coin -= 500
            if (coin <= 0):
                print("大了，剩余金币为：", coin, "个")
                print("-----金币为", coin, "游戏结束-----")
                break
            print("大了，剩余金币为：", coin, "个")
            d = int(input("请重新输入："))
        elif d < c:
            sum += 1
            coin -= 500
            if (coin <= 0):
                print("小了，剩余金币为：", coin, "个")
                print("-----金币为", coin, "游戏结束-----")
                break
            print("小了，剩余金币为：", coin, "个")
            d = int(input("请重新输入："))
        else:
            print("-----恭喜你答对了！！！-----")
            print("本轮幸运数字为：", c)
            sum += 1
            print("答题次数为：", sum)
            coin = coin + 3000
            print("剩余金币为：", coin, "个")
            print("如果要进行下一轮请按1")
            print("按2退出游戏")
            start2 = int(input("请输入："))
            if start2 == 1:
                continue_game(coin)
                break
            else:
                break
print("--------猜数字--------")
print("---------------------")
print("---------------------")
coin = 5000
print("你的起始金币有：",coin,"个")
print("错误一次损失500金币")
a = int(input("请输入第一个数字："))
b = int(input("请输入第二个数字："))
while a >= b:
    b = int(input("第二个数字不能小于或等于第一个数字，请重新输入："))
print("数字区间为（",a,"-",b,"）")
c = random.randint(a,b)
print("猜测开始！！！")
d = int(input("请输入所想数字："))
sum = 0
playing = True
while playing:
    if d > c:
        sum += 1
        coin -= 500
        if (coin <= 0):
            print("大了，剩余金币为：", coin, "个")
            print("-----金币为", coin, "游戏结束-----")
            break
        print("大了，剩余金币为：", coin, "个")
        d = int(input("请重新输入："))
    elif d < c:
        sum += 1
        coin -= 500
        if (coin <= 0):
            print("小了，剩余金币为：", coin, "个")
            print("-----金币为", coin, "游戏结束-----")
            break
        print("小了，剩余金币为：", coin, "个")
        d = int(input("请重新输入："))
    else:
        print("-----恭喜你答对了！！！-----")
        print("本轮幸运数字为：",c)
        sum += 1
        print("答题次数为：", sum)
        coin = coin + 3000
        print("剩余金币为：", coin, "个")
        print("如果要进行下一轮请按1")
        print("按2退出游戏")
        start2 = int(input("请输入："))
        if start2 == 1:
            continue_game(coin)
            break
        else:
            break